

bossbar set minecraft:boss players @a
# bossbar 在boss未入场之前 使用bossbar实时更新剩余选择boss的时间
execute if score ChangeBossTiming System matches 1.. store result bossbar minecraft:boss value run scoreboard players get ChangeBossTiming System

#【逢魔时刻】
execute if score DayTime System matches 16000 run scoreboard players set ChangeBossTiming System 121
execute if score DayTime System matches 16000 run title @a title [{"text":"","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute if score DayTime System matches 16000 run title @a subtitle [{"text":"逢魔时刻 ","color":"red","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"魔王降临","color":"dark_blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute if score DayTime System matches 16000 as @a run function nw:system/system_module/boss_menu

#创建并修改bossbar属性
execute if score ChangeBossTiming System matches 121 run bossbar remove minecraft:boss
execute if score ChangeBossTiming System matches 121 run bossbar add minecraft:boss {"text": "逢魔时刻","color": "red"}
execute if score ChangeBossTiming System matches 121 run bossbar set minecraft:boss color pink
execute if score ChangeBossTiming System matches 121 run bossbar set minecraft:boss style notched_12
execute if score ChangeBossTiming System matches 121 run bossbar set minecraft:boss visible true
execute if score ChangeBossTiming System matches 121 run bossbar set minecraft:boss max 120
execute if score ChangeBossTiming System matches 121 run scoreboard players remove ChangeBossTiming System 1

#【逢魔时刻】随机选择玩家成为魔王
execute if score ChangeBossTiming System matches 0 run tag @r[tag=BossSelectFinish] add BossAlready

#其他玩家设置为死亡 即进入观战模式
execute if score ChangeBossTiming System matches 0 run scoreboard players set @a[tag=BossSelectFinish,tag=!BossAlready] SystemDeath 2

#创建并修改bossbar属性
team join King @a[tag=BossAlready]
execute if score ChangeBossTiming System matches 0 run bossbar remove minecraft:boss
execute if score ChangeBossTiming System matches 0 as @a[tag=BossAlready] run bossbar add boss [{"selector":"@s","color":"dark_red","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute if score ChangeBossTiming System matches 0 run bossbar set minecraft:boss color pink
execute if score ChangeBossTiming System matches 0 run bossbar set minecraft:boss style notched_10
execute if score ChangeBossTiming System matches 0 run bossbar set minecraft:boss visible true



#【逢魔时刻】玩家成为魔王后进入战场
execute as @a[tag=BossAlready,tag=BossSelectFinish] run tellraw @a [{"selector":"@s","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":" 进入战场 ","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"其他玩家已自动组队","color":"green","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute as @a[tag=BossAlready,tag=BossSelectFinish] at @s run function nw:system/system_joinmap/joinmap
tag @a[tag=BossAlready,tag=BossSelectFinish] remove BossSelectFinish

#设置bossbar的最大值为boss玩家的最大血量
execute if score ChangeBossTiming System matches 0 store result bossbar minecraft:boss max run data get entity @a[tag=BossAlready,limit=1] Health
#关闭通道以及计时
execute if score ChangeBossTiming System matches 0 unless entity @a[tag=BossAlready] run tellraw @a [{"text":"没有人成为魔王 ","color":"white","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"逢魔时刻","color":"dark_red","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false},{"text":"结束","color":"white","bold":true,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}]
execute if score ChangeBossTiming System matches 0 run scoreboard players reset ChangeBossTiming System